# lib.syntax

- **Type:**

```ts
type EcmaScriptVersion =
  | 'es5'
  | 'es6'
  | 'es2015'
  | 'es2016'
  | 'es2017'
  | 'es2018'
  | 'es2019'
  | 'es2020'
  | 'es2021'
  | 'es2022'
  | 'es2023'
  | 'es2024'
  | 'esnext';

type Syntax = EcmaScriptVersion | string[];
```

- **Default:** `'esnext'`

Configure the syntax to which JavaScript and CSS will be downgraded.

See [Output Compatibility - Syntax Downgrade](/guide/advanced/output-compatibility) for more details.

## Set ECMAScript version

You can set the ECMAScript version directly, such as `es2015`, `es2022`, etc.

```ts title="rslib.config.ts"
export default {
  lib: [
    {
      syntax: 'es2015',
    },
  ],
};
```

## Set browserslist query

You can also set the [Browserslist query](https://browsersl.ist/), such as `last 2 versions`, `> 1%`, `node >= 16`, `chrome >= 80`, etc.

```ts title="rslib.config.ts"
export default {
  lib: [
    {
      syntax: ['last 2 versions', '> 1%'],
    },
  ],
};
```

## Mix ECMAScript version and browserslist query

You can also mix ECMAScript version and Browserslist query, such as `es2015` and `node 20`. Rslib will turn ECMAScript Version into Browserslist query, and then merge them together.

```ts title="rslib.config.ts"
export default {
  lib: [
    {
      syntax: ['es2015', 'node 20'],
    },
  ],
};
```
